home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 10
/
The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso
/
PC_SIGCD
/
01
/
6
/
DISK0162.ZIP
/
UTIL.DOC
< prev
next >
Wrap
Text File
|
1984-10-10
|
17KB
|
601 lines
October 1984
This document tells how to use the Structured BASIC program
debugger, lister, and library routines. These utilities make
writing Structured BASIC programs easier. This manual assumes you
are familiar with MS DOS and Microsoft BASIC.
THE BASIC NECESSITIES THE BASIC NECESSITIES
UTILITIES USER'S MANUAL UTILITIES USER'S MANUAL
Manual version: 1.12
Software version: 1.12
Marty Franz
525 W. Walnut St., Kalamazoo, MI 49007
(616) 344-1821
(C) Copyright 1983 Marty Franz - All rights reserved
100784112 Utilities User's Manual
INTRODUCTION INTRODUCTION
The BASIC Necessities is a complete BASIC programming system
for the IBM Personal Computer. It features a text editor for
entering and changing Structured BASIC statements, and a
preprocessor for converting Structured BASIC programs into BASIC
programs that can be executed on the PC. The preprocessor and
editor User's Manuals describe these programs in detail. This
manual concerns itself with several additional programs that can
make writing and debugging Structured BASIC programs easier:
- LLIST.EXE, a program to list your Structured BASIC
source files on a printer with your choice of several
formatting options,
- XREF.EXE, a cross-reference generator,
- ENTAB, DETAB, and ARCH, convenient utility programs,
- DEBUG.INC, a debugger module that lets you debug your
Structured BASIC programs at the procedure level, and
- the files SCREEN.INC, CLS.INC, and INPUT.INC, library files
containing procedures that can be included into your
Structured BASIC programs to make your programming easier.
PROGRAM REQUIREMENTS PROGRAM REQUIREMENTS
To successfully use these utility programs, your need an IBM
PC, XT, or jr with:
- at least 64KB of memory,
- at least one single-sided diskette drive,
- a color or monochrome adapter, and a monitor capable of
displaying 80-character lines,
- MS DOS version 1.1 or 2.0, and
- the files BASICA.COM or BASIC.COM.
Page 2 100784112 Utilities User's Manual
THE PROGRAM DEBUGGER THE PROGRAM DEBUGGER
The Structured BASIC program debugger is used during
development to trace Structured BASIC program execution at the
procedure level. (For more information about "procedures" and the
rest of the Structured BASIC language, please consult the
Structured BASIC User's Manual.) By including the file DEBUG.INC
in your program during preprocessing, and using the DEBUG and
NODEBUG statements, you can perform these helpful functions when
you are testing your program from within BASIC:
- you can see the execution of each procedure on the screen
as it is called by a DO or GOSUB statement,
- you can set a trap in your program to stop when a certain
procedure is reached, (this is called a "breakpoint")
- you can stop your program, exit into BASIC, print the
values of your variables, then resume execution again, and
- you can dump the "stack" of procedures called whenever you
stop the program's execution.
USING THE DEBUGGER USING THE DEBUGGER
To use the program debugger, you need to include the file
DEBUG.INC into your Structured BASIC source program. Then, you
must select the individual procedures to be debugged by using the
DEBUG and NODEBUG Structured BASIC statements. Here's an
example:
INCLUDE DEBUG.INC 'Include the debugger procedures.
DEBUG 'Turn on debugging.
PROCEDURE MAIN 'First procedure to be debugged.
.
.
ENDPROC
PROCEDURE ...
. 'More procedures to be debugged are
. here.
ENDPROC
NODEBUG 'Turn off debugging.
INCLUDE SCREEN.INC 'Procedures here will not be
debugged.
The statements DEBUG and NODEBUG work just like a switch. When
DEBUG is encountered, all the procedures following it will have
Page 3 100784112 Utilities User's Manual
calls to debugger routines generated after their first and last
statements. When NODEBUG is reached, this generation is turned
off. Both DEBUG and NODEBUG must appear in a source file outside
a procedure. When you run your program from BASIC, these extra
calls help the debugger determine where in execution is in the
program.
DEBUGGING IN BASIC DEBUGGING IN BASIC
After your program has been preprocessed with debugger
statements in it, it can be run from BASIC. The debugger will
get control before procedure MAIN does, and will display a list
of available commands and prompt you for one with "debug:"
displayed on line 25 of the screen. The commands you can use in
the debugger are:
X to exit to BASIC with a STOP statement. This
allows you to print key variables in your program
and list parts of your code. The BASIC CONT
command can be used to continue execution.
B to have the debugger prompt you for a breakpoint.
Enter the name of the procedure where you want the
program to stop next. If you don't want to stop at
any procedures during execution, just press enter.
D to display the names of the procedures currently
active, along with their appropriate line numbers.
This will be shown enclosed by a frame in the
upper right corner of your screen. The topmost
procedure in the list will be the one currently
being executed, with the one below it being the one
that called it, etc. This can be used to help you
trace the location of bugs in the program.
G to resume execution of the program.
As your program is running, the procedures being executed are
displayed on line 25 of the screen along with the line number
they start on. You can stop execution of the program at any time
by pressing F10. This will enter the debugger at the next
procedure encountered.
Besides stopping at a breakpoint or by F10 on the keyboard,
the debugger is entered whenever a BASIC error is encountered.
The error message and line number will be displayed on line 25 of
the screen. A line number of 65535 means the error happened in
direct mode.
The debugger is in Structured BASIC source code and can be
changed for special needs. You might want to do this if you are
developing programs that do a lot of color or graphics, since the
debugger assumes a text screen with 25 lines of 80 characters.
All of the debugger's variable definitions are contained in the
procedure DEBUG.SETUP, which is called before MAIN is when your
Page 4 100784112 Utilities User's Manual
program is started.
Page 5 100784112 Utilities User's Manual
THE LLIST PROGRAM THE LLIST PROGRAM
The file LLIST.EXE on your Structured BASIC program disk is a
general-purpose print utility. With it, you can print your
Structured BASIC source files, selecting any of several
formatting options.
LLIST's syntax is similar to other MS DOS commands. You must
supply it the name of the file you want to list, and additional
information through program "switches" to select any extra
formatting options. LLIST's format is:
A>LLIST {/n /p /s /ln /wn /tn} file1 file2 ...
Only a file name is required. An extension of .SB is always
assumed. You must put the switches before the names of the files
you want them to effect. The switches control these options:
/n omits page headings from the listing. Normally,
your listing will have the filename, date, time,
and page number at the top of each page. The /n
switch overrides this.
/p is used when you are printing on single-sheet
paper. This will pause the program between pages
so you can change sheets. Press the "enter" key
to continue with the next page.
/s includes line numbers in the listing. This switch
is especially useful when you are debugging
Structured BASIC programs and you need to match
the line numbers of the preprocessor's error
messages to the source statement.
/ln sets the length of a page to n lines. This is
useful when printing on short forms or in
compressed format. Normally, this option is set
to 60 lines/page.
/tn sets tab stops every n columns. Normally, you
don't need to use this with Structured BASIC
source files, since it is set by default to 4
columns. You might need to change this option for
other languages like Pascal or C. The maximum tab
setting allowed is 10.
Page 6 100784112 Utilities User's Manual
/wn sets the width of a page to n characters/line.
Use this option for printing in compressed format,
since the default is 80 characters/line. Up to
132 characters may be used.
Note: _____
This option is unaffected by the setting of the MS
DOS "mode" command.
For normal use printing Structured BASIC source files, you
shouldn't need to use any of these options. Here are some
examples of LLIST:
A>llist a:debug.inc
prints the file A:DEBUG.INC with standard tabs,
page length (60 lines/page), and page width (80
characters/line).
A>llist /t2 /p screen.inc
prints SCREEN.INC from the A: drive with tabs set
every 2 columns and a pause after every page.
A>llist /w132 /l82 /p b:input.inc
prints the file INPUT.INC on drive B: with a page
width of 132 characters/line and a page length of
82 lines/page. The switch /p is used to that the
paper can be manually advanced after every page.
This combination of options can be used for
extremely compressed listings on an Epson or IBM PC
printer.
Page 7 100784112 Utilities User's Manual
THE XREF PROGRAM THE XREF PROGRAM
The XREF.EXE program generates cross-references of your
Structured BASIC source files. The cross-reference report
consists of a source listing with line numbers, followed by a
table showing all the variables, procedure names, and statement
labels in alphabetical order and a list of the line numbers that
use them. XREF's format is:
A>XREF {/i /r /ln /wn /tn} file1 file2 ...
Only a file name is required. An extension of .SB is always
assumed. You must put the switches before the names of the files
you want them to effect. The switches control these options:
/i cross references any INCLUDE files referenced in
the file. This option can generate a lot of
listing.
/r Includes the names of reserved words (OPEN, IF,
PRINT, etc.) in the report. A useful option when
resolving variable name conflicts or converting
programs from other versions of BASIC.
/ln sets the length of a page to n lines. This is
useful when printing on short forms or in
compressed format. Normally, this option is set
to 60 lines/page.
/tn sets tab stops every n columns. Normally, you
don't need to use this with Structured BASIC
source files, since it is set by default to 4
columns. You might need to change this option for
other languages like Pascal or C. The maximum tab
setting allowed is 10.
Page 8 100784112 Utilities User's Manual
/wn sets the width of a page to n characters/line.
Use this option for printing in compressed format,
since the default is 80 characters/line. Up to
132 characters may be used.
Note: _____
This option is unaffected by the setting of the MS
DOS "mode" command.
Page 9 100784112 Utilities User's Manual
SAMPLE LIBRARY FILES SAMPLE LIBRARY FILES
The files SCREEN.INC, CLS.INC, and INPUT.INC on the
Structured BASIC program disk contain several useful procedures
for handling screen input and output.
SCREEN.INC contains routines for drawing boxes and frames on
the screen, putting status messages on line 24, and drawing
titles and headings.
CLS.INC has an assembly language routine and two procedures
that make clearing areas on the screen from your programs much
faster. (Prior to this, you had to output blank strings to clear
several lines. This was very slow and made screen-oriented
programs slow as a result.)
INPUT.INC contains routines for getting strings with INKEY$,
reading a single character from the keyboard, and simulating a
blinking cursor under program control.
These library files can be included in your programs with the
statements:
INCLUDE SCREEN.INC (automatically includes CLS.INC)
and
INCLUDE INPUT.INC
Descriptions of the routines can be found in the files
themselves. Studying them is also a good way to learn more about
using Structured BASIC. The sample Structured BASIC programs
CHARS.SB, ATTRIB.SB and SDIR.SB all make use of these
procedures.
Page 10 100784112